home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
ccdl150l.zip
/
IO
/
FGETS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-26
|
320b
|
22 lines
#include <stdio.h>
char *fgets(char *buf, int num, FILE *stream)
{
int i = 0,rv;
while (1) {
rv = fgetc(stream);
if (rv == EOF)
break;
if (--num) {
buf[i++] = (char)rv;
if (rv == '\n')
break;
}
else
break;
}
buf[i] = 0;
if (rv == EOF)
return 0;
else return buf;
}